(function ($, doc) {
	$.init();

	function getQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return decodeURIComponent(r[2]);
		return "";
	}

	window.onload = function() {
//		var tradetext = localStorage.getItem('$tradelist') || "{}";
//		var obj = JSON.parse(tradetext)

		var getUrl = apiurl + "wallet/getTradeDetail/?tradeid=" + getQueryString("tradeid");
		$.getJSON(getUrl, function (res) {
			if (res.status == 1) {
				var detail = template('list-template', {
					"tradeinfo": res.data
				});

				doc.getElementById("tradedetail").innerHTML = detail;
			} else {
				mui.alert(res.msg);
			}
		});
	}

	var clipboard1 = new Clipboard('#li_trade_out_no');
	var clipboard2 = new Clipboard('#li_from_addr');
	var clipboard3 = new Clipboard('#li_to_addr');

    clipboard1.on('success', function(e) {
		console.log(e);
		mui.toast("已复制交易号");
    });
    clipboard2.on('success', function(e) {
		console.log(e);
		mui.toast("已复制支付钱包地址");
	});    
	clipboard3.on('success', function(e) {
		console.log(e);
		mui.toast("已复制收钱钱包地址");
    });
    clipboard1.on('error', function(e) {
        console.log(e);
	});
}(mui, document));

function openUrl(url)
{
	plus.runtime.openURL(url);
}